package com.etc;

import javax.xml.parsers.SAXParser;
import java.util.Random;

/**
 * 小蜜蜂
 */
public class Bee extends FlyingObject implements Award{

    // x 坐标步数
    private int xSpeed = 1;
    // y 坐标步数
    private int ySpeed = 2;
    // 奖励类型
    private int awardType;

    public Bee() {
        image = AircraftwarGame.bee;
        width = image.getWidth();
        height = image.getHeight();
        Random random = new Random();
        x = random.nextInt(AircraftwarGame.WIDTH - this.width);
        y = -height;
        this.awardType = random.nextInt(2);
    }

    /**
     * 获得奖励
     * @return
     */
    @Override
    public int getType() {
        return this.awardType;
    }




    @Override
    public void step() {
        x = x + xSpeed;
        y = y + ySpeed;
        if (this.x >= AircraftwarGame.WIDTH - this.width){
            xSpeed = -1;
        }
        if (this.x <= 0){
            xSpeed = 1;
        }
    }

    @Override
    public boolean outBounds() {
        return  this.y > AircraftwarGame.HEIGHT ? true:false ;
    }
}
